Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 요약
다단계 폼(Multi-step Form) UI에서 step 제어 로직과 렌더링 조건이
컴포넌트 전반에 흩어지는 문제를 해결하기 위해
useMultiForm 커스텀 훅 추가
Compound Component 패턴을 사용해
폼 흐름을 선언적으로 구성할 수 있도록 설계했습니다.
문제 배경
기존의 다단계 폼 구현에서는 다음과 같은 문제가 있었습니다.
if (step === n)형태의 분기문이 많아 가독성이 떨어짐이로 인해 유지보수성과 확장성이 저하되는 문제가 있었습니다.
💡 해결 방법 (How)
step 상태와 흐름 제어를 하나의 훅으로 캡슐화하고,
Compound Component 패턴을 활용해
JSX 레벨에서 선언적으로 step 구조를 표현하도록 개선했습니다.
🧩 설계 구조
useMultiForm역할
nowStep: 현재 step 상태handleStep: step 이동 제어 함수 (next,before)Step: 각 step UI를 선언적으로 정의하는 컴포넌트MultiForm: 현재 step에 해당하는Step만 렌더링하는 컨테이너<Step /><MultiForm />Step중nowStep과 일치하는Step만 선택하여 렌더링사용 예시
기대 효과